﻿namespace Hardcodet.Wpf.TaskbarNotification
{
    using System;
    using System.Windows;

    internal static class RoutedEventHelper
    {
        internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
        {
            UIElement element2 = element as UIElement;
            if (element2 != null)
            {
                element2.AddHandler(routedEvent, handler);
            }
            else
            {
                ContentElement element3 = element as ContentElement;
                if (element3 != null)
                {
                    element3.AddHandler(routedEvent, handler);
                }
            }
        }

        internal static void RaiseEvent(DependencyObject target, RoutedEventArgs args)
        {
            if (target is UIElement)
            {
                (target as UIElement).RaiseEvent(args);
            }
            else if (target is ContentElement)
            {
                (target as ContentElement).RaiseEvent(args);
            }
        }

        internal static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
        {
            UIElement element2 = element as UIElement;
            if (element2 != null)
            {
                element2.RemoveHandler(routedEvent, handler);
            }
            else
            {
                ContentElement element3 = element as ContentElement;
                if (element3 != null)
                {
                    element3.RemoveHandler(routedEvent, handler);
                }
            }
        }
    }
}

